//
//  FixedCharRecord.m
//  SimulacraDB
//
//  Created by Andre Cohen on 9/1/08.
//  Copyright 2008 __MyCompanyName__. All rights reserved.
//

#import "FixedCharRecord.h"


@implementation FixedCharRecord

@dynamic maxLength; 

- (void)init {
	[super init];
	maxLength = -1;
}

- (void)setValue:(NSObject *)data {
	[super setValue:data];
	[self setMaxLength:maxLength];
}

- (void)setMaxLength:(int)len {
	maxLength = len;
	
	if(maxLength<0 || value==nil)
		return;
	
	if([[self value] length]<len) {
		value = [NSMutableString stringWithString:value];
		for(len=len-[value length];len>0;len--)
			[(NSMutableString *)value appendString:@" "];
	} else {
		value = NULL;
	}
}

@end
